package com.itheima.d7_interface_demo.demo;

import com.itheima.d7_interface_demo.demo.StudentServiceImpl2;

import java.util.ArrayList;

/**
 * 模拟管理系统
 */
public class ClassManager {
    //数据
    //学生的数据
    private ArrayList<Student> students = new ArrayList<>();

    //打印方法
//    private StudentService studentService = new StudentServiceImpl1(); //使用方案1
    private StudentService studentService = new StudentServiceImpl2(); //使用方案2

    public ClassManager() {
        students.add(new Student("迪丽热巴", '女', 99));
        students.add(new Student("古力娜扎", '女', 100));
        students.add(new Student("马尔扎哈", '男', 80));
        students.add(new Student("卡尔扎巴", '男', 60));
    }

    //功能
    //打印全班学生信息
    public void printInfo() {
//        System.out.println("----------全班学生信息如下---------");
//        for (int i = 0; i < students.size(); i++) {
//            Student stu = students.get(i);
//            System.out.println("姓名：" + stu.getName() + "，性别" + stu.getSex() + "，成绩：" + stu.getScore());
//        }
//        System.out.println("-----------------------");

        studentService.printAllInfo(students);
    }

    //打印分数
    public void printScore() {
//        //求总分
//        double sum = 0;
//        for (int i = 0; i < students.size(); i++) {
//            Student stu = students.get(i);
//            sum += stu.getScore(); //累加
//        }
//        //求平均分
//        System.out.println("平均分：" + (sum / students.size()));

        studentService.printAverageScore(students);
    }
}
